-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DefaultEndpointResolver to the orchestrator #2577
Conversation
This commit adds `DefaultEndpointResolver` to the orchestrator. The type implements the `EndpointResolver` trait and takes over the work previously done by `make_operation` and `SmithyEndpointStage`.
This commit places `DefaultEndpointResolver` and endpoint params builder in the config bag from within `ServiceRuntimePlugin`. Notice we put a builder, not endpoint params, because full construction of endpoint params requires additional values to be set from an operation input, which will later be handled by an interceptor.
This commit generates interceptors for configuring endpoint params in the orchestrator. There are two interceptors: one is to update params builder with operation specific information, e.g. a bucket name, and the other is to convert the params builder to the actual endpoint params by calling `.build`.
This commit adds a codegen decorator to register interceptors to `OperationRuntimePlugin`.
This commit replaces `StaticUriEndpointResolver` with `DefaultEndpointResolver` in `sra_test` to ensure the test continues to work end-to-end.
A new generated diff is ready to view.
A new doc preview is ready to view. |
This commit allows the `clippy::useless_conversion` only when `enableNewSmithyRuntime` is true. When we stop rendering an endpoint prefix in `make_operation` after completingly switching over to the orchestrator world, we can remove the attribute.
A new generated diff is ready to view.
A new doc preview is ready to view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this PR since I was out last week. I have some comments around errors.
.../smithy/rust/codegen/client/smithy/endpoint/generators/EndpointParamsInterceptorGenerator.kt
Show resolved
Hide resolved
.../smithy/rust/codegen/client/smithy/endpoint/generators/EndpointParamsInterceptorGenerator.kt
Show resolved
Hide resolved
.../smithy/rust/codegen/client/smithy/endpoint/generators/EndpointParamsInterceptorGenerator.kt
Show resolved
Hide resolved
.../smithy/rust/codegen/client/smithy/endpoint/generators/EndpointParamsInterceptorGenerator.kt
Show resolved
Hide resolved
HeaderName::from_str(header_name).map_err(|err| { | ||
ResolveEndpointError::message("invalid header name") | ||
.with_source(Some(err.into())) | ||
})?, | ||
HeaderValue::from_str(value).map_err(|err| { | ||
ResolveEndpointError::message("invalid header value") | ||
.with_source(Some(err.into())) | ||
})?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these errors even be possible if the endpoint config is valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not entirely sure. I've decided to preserve the existing error handling logic from the original PR for the sake of porting. I don't see how an endpoint resolver comes into being after a series of config steps in the orchestrator world is all that different from the old world, so maybe it makes sense to keep the existing error handling for now (we can later turn them into non-recoverable errors, if we want).
This commit incorporates the following feedback: #2577 (comment) #2577 (comment) #2577 (comment) #2577 (comment)
This commit addresses #2577 (comment)
## Motivation and Context This PR incorporates post-merge feedback left in #2577. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: Yuki Saito <awsaito@amazon.com>
This commit ports fixes made in #2592, which addresses the following #2577 (comment)
## Motivation and Context This PR adds `DefaultEndpointResolver`, a default implementer of the [EndpointResolver](https://github.com/awslabs/smithy-rs/blob/1e27efe05fe7b991c9f9bbf3d63a297b2dded334/rust-runtime/aws-smithy-runtime-api/src/client/orchestrator.rs#L182-L184) trait, to the orchestrator. ## Description Roughly speaking, the endpoint-related work is currently done by `make_operation` and `SmithyEndpointStage`, where `make_operation` constructs endpoint params and applies an endpoint resolver and the `SmithyEndpointStage` later updates the request header based on the resolved endpoint. In the orchestrator world, that work is handled by `DefaultEndpointResolver::resolve_and_apply_endpoint`. The way endpoint parameters and an endpoint prefix are made available to `DefaultEndpointResolver::resolve_and_apply_endpoint` is done by interceptors because they _may_ require pieces of information only available in an operation input struct. The place that has access to both an operation input struct and a config bag happens to be an interceptor. There are two interceptors `<Operation>EndpointParamsInterceptor` and `<Operation>EndpointParamsFinalizerInterceptor` per operation. We pass around endpoint params _builder_ through interceptors to allow it to be configured with more information at a later point; An end point parameters builder is first initialized within the `ServiceRuntimePlugin` with the field values obtained from the service config, and is stored in a config bag. The finalizer interceptor "seals" the builder and creates the actual endpoint params before it is passed to `DefaultEndpointResolver::resolve_and_apply_endpoint`. These interceptors implement `read_before_execution` because they need to access an operation input before it gets serialized (otherwise, `context.input()` would return a `None`). ## Testing Replaced `StaticUriEndpointResolver` with `DefaultEndpointResolver` in `sra_test` and verified the test continued passing. UPDATE: The test currently fails in the `main` branch (it returns a `None` when extracting `SigV4OperationSigningConfig` from the config bag in `OverrideSigningTimeInterceptor`, hence `unwrap` fails), and by merging the `main` branch this PR no longer passes the test, but it does not add new failures either. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: Yuki Saito <awsaito@amazon.com>
## Motivation and Context This PR incorporates post-merge feedback left in #2577. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: Yuki Saito <awsaito@amazon.com>
## Motivation and Context This PR adds `DefaultEndpointResolver`, a default implementer of the [EndpointResolver](https://github.com/awslabs/smithy-rs/blob/1e27efe05fe7b991c9f9bbf3d63a297b2dded334/rust-runtime/aws-smithy-runtime-api/src/client/orchestrator.rs#L182-L184) trait, to the orchestrator. ## Description Roughly speaking, the endpoint-related work is currently done by `make_operation` and `SmithyEndpointStage`, where `make_operation` constructs endpoint params and applies an endpoint resolver and the `SmithyEndpointStage` later updates the request header based on the resolved endpoint. In the orchestrator world, that work is handled by `DefaultEndpointResolver::resolve_and_apply_endpoint`. The way endpoint parameters and an endpoint prefix are made available to `DefaultEndpointResolver::resolve_and_apply_endpoint` is done by interceptors because they _may_ require pieces of information only available in an operation input struct. The place that has access to both an operation input struct and a config bag happens to be an interceptor. There are two interceptors `<Operation>EndpointParamsInterceptor` and `<Operation>EndpointParamsFinalizerInterceptor` per operation. We pass around endpoint params _builder_ through interceptors to allow it to be configured with more information at a later point; An end point parameters builder is first initialized within the `ServiceRuntimePlugin` with the field values obtained from the service config, and is stored in a config bag. The finalizer interceptor "seals" the builder and creates the actual endpoint params before it is passed to `DefaultEndpointResolver::resolve_and_apply_endpoint`. These interceptors implement `read_before_execution` because they need to access an operation input before it gets serialized (otherwise, `context.input()` would return a `None`). ## Testing Replaced `StaticUriEndpointResolver` with `DefaultEndpointResolver` in `sra_test` and verified the test continued passing. UPDATE: The test currently fails in the `main` branch (it returns a `None` when extracting `SigV4OperationSigningConfig` from the config bag in `OverrideSigningTimeInterceptor`, hence `unwrap` fails), and by merging the `main` branch this PR no longer passes the test, but it does not add new failures either. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: Yuki Saito <awsaito@amazon.com>
## Motivation and Context This PR incorporates post-merge feedback left in #2577. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: Yuki Saito <awsaito@amazon.com>
## Motivation and Context - #2577 added a `Debug` bound on `ResolveEndpoint`, but this was a semver-incompatible change ## Description This removes that bound but re-adds a Debug implementation in areas that we need them ## Testing - CI - [ ] Backport this commit to main ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
## Motivation and Context Port #2630 to the `main` branch. ## Description Adding `Debug` bound on `ResolveEndpoint` in #2577 was a breaking change. Unfortunately, the semvar check that ran in that PR barked at a different thing (i.e. barked at moving `StaticUriEndpointResolver` and `DefaultEndpointResolver` from `aws-smithy-runtime-api` to `aws-smithy-runtime`). Eventually the breaking change got merged to the `main` branch. This PR reverts the change in question and implements the `Debug` trait for `ResolveEndpoint` in a semvar non-breaking way. ## Testing - [ ] Passed tests in CI ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ Co-authored-by: Yuki Saito <awsaito@amazon.com>
Port #2630 to the `main` branch. Adding `Debug` bound on `ResolveEndpoint` in #2577 was a breaking change. Unfortunately, the semvar check that ran in that PR barked at a different thing (i.e. barked at moving `StaticUriEndpointResolver` and `DefaultEndpointResolver` from `aws-smithy-runtime-api` to `aws-smithy-runtime`). Eventually the breaking change got merged to the `main` branch. This PR reverts the change in question and implements the `Debug` trait for `ResolveEndpoint` in a semvar non-breaking way. - [ ] Passed tests in CI ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ Co-authored-by: Yuki Saito <awsaito@amazon.com>
Port #2630 to the `main` branch. Adding `Debug` bound on `ResolveEndpoint` in #2577 was a breaking change. Unfortunately, the semvar check that ran in that PR barked at a different thing (i.e. barked at moving `StaticUriEndpointResolver` and `DefaultEndpointResolver` from `aws-smithy-runtime-api` to `aws-smithy-runtime`). Eventually the breaking change got merged to the `main` branch. This PR reverts the change in question and implements the `Debug` trait for `ResolveEndpoint` in a semvar non-breaking way. - [ ] Passed tests in CI ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ Co-authored-by: Yuki Saito <awsaito@amazon.com>
Motivation and Context
This PR adds
DefaultEndpointResolver
, a default implementer of the EndpointResolver trait, to the orchestrator.Description
Roughly speaking, the endpoint-related work is currently done by
make_operation
andSmithyEndpointStage
, wheremake_operation
constructs endpoint params and applies an endpoint resolver and theSmithyEndpointStage
later updates the request header based on the resolved endpoint. In the orchestrator world, that work is handled byDefaultEndpointResolver::resolve_and_apply_endpoint
.The way endpoint parameters and an endpoint prefix are made available to
DefaultEndpointResolver::resolve_and_apply_endpoint
is done by interceptors because they may require pieces of information only available in an operation input struct. The place that has access to both an operation input struct and a config bag happens to be an interceptor.There are two interceptors
<Operation>EndpointParamsInterceptor
and<Operation>EndpointParamsFinalizerInterceptor
per operation. We pass around endpoint params builder through interceptors to allow it to be configured with more information at a later point; An end point parameters builder is first initialized within theServiceRuntimePlugin
with the field values obtained from the service config, and is stored in a config bag. The finalizer interceptor "seals" the builder and creates the actual endpoint params before it is passed toDefaultEndpointResolver::resolve_and_apply_endpoint
. These interceptors implementread_before_execution
because they need to access an operation input before it gets serialized (otherwise,context.input()
would return aNone
).Testing
Replaced
StaticUriEndpointResolver
withDefaultEndpointResolver
insra_test
and verified the test continued passing.UPDATE: The test currently fails in the
main
branch (it returns aNone
when extractingSigV4OperationSigningConfig
from the config bag inOverrideSigningTimeInterceptor
, henceunwrap
fails), and by merging themain
branch this PR no longer passes the test, but it does not add new failures either.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.